package at.com.vn.chess.util;

import java.awt.Rectangle;

public class RectangleUtils {
	
	public static boolean isInSameRow( Rectangle rect1, Rectangle rect2 ) {
		return rect1.y == rect2.y;
	}
	
	public static boolean isInSameColumn( Rectangle rect1, Rectangle rect2 ) {
		return rect1.x == rect2.x;
	}
	
	public static boolean isNextRow( Rectangle currentRect, Rectangle nextRect ) {
		return nextRect.y - currentRect.y == nextRect.height;
	}
	
	public static boolean isNextNextRow( Rectangle currentRect, Rectangle nextRect ) {
		return nextRect.y - currentRect.y == 2 * nextRect.height;
	}
	
	public static boolean isColumnBeside( Rectangle currentRect, Rectangle nextRect ) {
		return Math.abs( nextRect.x - currentRect.x ) == nextRect.width;
	}
	
	public static boolean isTrenMotDuongCheo( Rectangle rect1, Rectangle rect2 ) {
		int dx = rect1.x - rect2.x;
		int dy = rect1.y - rect2.y;
		
		if( dx == 0 || dy == 0 || Math.abs( dx / rect1.width ) != Math.abs( dy / rect1.height )) {
			return false;
		}
		
		return true;
	}
	
	public static int convertToRealBoardRow( Rectangle rect ) {
		return rect.y / rect.height - 1;
	}
	
	public static int convertToRealBoardCol( Rectangle rect ) {
		return rect.x / rect.width - 4;	
	}
	
	public static int convertToActiveBoardRow( Rectangle rect ) {
		return rect.y / rect.height - 1;
	}
	
	public static int convertToActiveBoardCol( Rectangle rect ) {
		return rect.x / rect.width;	
	}
	
		
//	public static void makeSymmetry( Point point ) {
//		point.x = 2 * SYMMETRY_POINT - point.x;
//		point.y = 2 * SYMMETRY_POINT - point.y; 
//	}
	
	public static void main( String[] args ) {
//		Point toaDo = new Point( 6, 2);
//		
//		makeSymmetry( toaDo );
//		
//		System.out.println( toaDo.x + ", " + toaDo.y );
		
		Cell cell = new Cell( 1, 7 );
		cell.makeSymmetry();
		System.out.println( cell.row + ", " + cell.col );
	}
	
}
